﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using EraNet.Services.Drivings;
using EraNet.Core.Model.Drivings;

namespace EraNet.SysAdmin.Controllers
{
    public class DrivingSchoolController : Controller
    {
        #region Fields

        private readonly IDrivingSchoolService _drivingSchoolService;

        #endregion

        #region Constructors

        public DrivingSchoolController(IDrivingSchoolService drivingSchoolService)
        {
            this._drivingSchoolService = drivingSchoolService;
        }

        #endregion

        //
        // GET: /DrivingSchool/

        public ActionResult Index()
        {
            #region old

            //for (int i = 0; i < 20; i++)
            //{
            //    #region 新增一个实体
            //    DrivingSchool entity = new DrivingSchool();
            //    entity.DrivingGuid = Guid.NewGuid().ToString();
            //    entity.ParentId = 0;
            //    entity.DrivingName = "我的测试驾校"+i;
            //    entity.SchoolLicense = "111"+i;
            //    entity.SchoolLevel = 1;
            //    entity.Corporation = "1"+i;
            //    entity.CorTel = "1"+i;
            //    entity.CertificateType = 1;
            //    entity.CorAttach = "1"+i;
            //    entity.Rector = "1"+i;
            //    entity.RectorTel = "1"+i;
            //    entity.Telephone = "1"+i;
            //    entity.Scale = "1"+i;
            //    entity.Cachet = "1"+i;
            //    entity.ProvinceId = i;
            //    entity.CityId = i;
            //    entity.Address = "1"+i;
            //    entity.Scope = "1"+i;
            //    entity.IsPayment = 1;
            //    entity.IsActive = 1;
            //    entity.Intro = "1"+i;
            //    entity.CurrentState = 1;
            //    entity.IsEnableWebSite = 1;
            //    entity.CreateDate = DateTime.Now;
            //    entity.Operater = "1"+i;
            //    entity.UpdateTime = DateTime.Now;
            //    entity.UpdateOperater = null;
            //    entity.SecurityCode = null;
            //    entity.SchoolCode = null;
            //    entity.ShortName = null;
            //    entity.InterfaceId = i;

            //    #endregion

            //    bool result = _drivingSchoolService.AddEntity(entity);
            //}
            #endregion

            return View();
        }

        #region 驾校基本信息

        //新增驾校
        public ActionResult AddDrivingSchool()
        {
            return View();
        }

        [HttpPost]
        public ActionResult AddDrivingSchool(DrivingSchool drivSchool)
        {
            return View();
        }

        //驾校列表页
        public ActionResult DrivingSchoolList()
        {
            //int pageCount=0;
            //var list = _drivingSchoolService.GetPageList<int>(ds => ds.Id > 1, 1, 10, ds => ds.Id, out pageCount);

            return View();
        }

        //ajax获取驾校列表数据
        public JsonResult AjaxGetDrivSchList(int? page)
        {
            int pageIndex = page ?? 1;
            int pageSize = 10;
            int pageCount = 0;
            List<DrivingSchool> list = _drivingSchoolService.GetPageList<int>(ds => true,pageIndex,pageSize,ds=>ds.Id,out pageCount);
            return Json(new { total = pageCount, list = list }, JsonRequestBehavior.AllowGet);
        }

        #endregion

    }
}
